To this point in your object-oriented design work, you have been considering the design of classes mostly in isolation. When you move to the development of larger software systems those skills need to be expanded. You need to begin considering how classes effect other classes, and how they interact with each other. There are a number of principles that have been put forward for quality object-oriented designs. We will discuss object-oriented design in more detail in two lessons. Each lesson will focus on design principles from the two sets of principles known as SOLID and GRASP (General responsibility assignment software patterns/principles). This first lesson will also cover the Law of Demeter.
This lesson will look at these principles:
Single responsibility (SOLID)
Open/Closed (SOLID)
Dependency inversion/injection (SOLID)
Controller (GRASP)
Information expert (GRASP)
Low coupling (GRASP)
Pure Fabrication (GRASP)
Law of Demeter
Learning Outcomes
Describe the principles: Single responsibility, Dependency inversion/injection
Give an example of a design that observes the single responsibility principle and one that does not.
Explain how dependency injection is helpful for testing
Explain why low coupling and high cohesion are principles in tension with each other
Explain the Law of Demeter and why violations of the law increase the coupling in a system
Explain how the Information expert design principle enforces behavior follows data
Analyze an object-oriented software design for adherence to these design principles.
Study Resources
For your study of this topic, use these resources.
Learning S.O.L.I.D. Programming Principles by Steven Lott available on lynda.com through the RIT library. The examples are in Python but the principles still hold.
(3:12)
(3:58)
(up to 4:00) - Ignore Adapter pattern reference for now
Beginning SOLID Principles and Design Patterns for ASP.NET Developers by Bipin Joshi available on O'Reilly
Chapter 2 - SOLID Principles as well as the links to its sections Single Responsibility Principle (SRP), and Dependency Inversion Principle (DIP) Only (SRP),(LSP) and (DRP) for now
The completion of this exercise may be delayed until just before you complete your implementation of the Elaboration phase user stories. The team should look to complete this soon rather than leaving things until the last minute. Make sure to keep track of this work to not have it surprise you when it is shown as due in the schedule.
For this exercise, you will look at the design of your term project in the Elaboration phase considering two of the five design principles covered in this lesson.
Single responsibility
Low coupling
Information expert
Dependency inversion/injection
Law of Demeter
For each principle, do the following:
Describe how the principle is applied in your design
Suggest improvements to your current design to get better adherence to the principle
This is an individual exercise. Across the team, each of the five design principles must be covered at least once by some team member, but none should be covered by more than two team members.
Your discussion of each principle should be one to two pages including any UML class structure diagrams that will be helpful to include.
By the date specified in your section's schedule, submit a Word or PDF file to the myCourses dropbox, Object-oriented design - individual, in the Exercises section.
End-Of-Day Exercises
Object-oriented design - quiz (2 exercise points)
Watch the videos listed by DevExpress CTO Messages and Learning S.O.L.I.D. Programming Principles. Read all of the book sections listed from GRASP Patterns Patterns in Java and Beginning SOLID Principles and Design Patterns. Complete the quiz, Object-oriented design I, in the myCourses quiz area before the start of the class indicated in your section's schedule.